package com.spzx.channel.service.Impl;

import com.spzx.channel.service.IProductService;
import com.spzx.common.core.constant.SecurityConstants;
import com.spzx.common.core.domain.R;
import com.spzx.common.core.web.page.TableDataInfo;
import com.spzx.product.api.RemoteProductService;
import com.spzx.product.api.domain.vo.SkuQuery;
import jakarta.servlet.ServletException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * projectName: spzx-parent
 *
 * @author: 王宝贵
 * time: 2024/10/9 14:30 周三
 * description:
 */
@Service
public class ProductServiceImpl implements IProductService {

    @Autowired
    private RemoteProductService remoteProductService;

    /**
     * 根据条件查询商品列表的信息
     * @param pageNum
     * @param pageSize
     * @param skuQuery 条件
     * @return 返回分页信息
     */
    @Override
    public TableDataInfo skuList(Integer pageNum, Integer pageSize, SkuQuery skuQuery) throws ServletException {
        R<TableDataInfo> tableDataInfoR = remoteProductService.skuList(pageNum, pageSize, skuQuery, SecurityConstants.INNER);
        if(tableDataInfoR.getCode() == R.FAIL){
            //出现异常
            throw  new ServletException("条件查询商品信息出错了" +tableDataInfoR.getMsg());
        }
        return tableDataInfoR.getData();
    }
}